package com.fengye.model;

import java.io.Serializable;
import java.lang.reflect.Method;

/**
 * 服务注册中心的服务提供者注册信息
 *
 * @Author fengye
 * @Date 2023/2/13 11:49
 **/
public class ProviderService implements Serializable {
    private static final long serialVersionUID = -7776073686642645441L;

    /** 服务提供者class */
    private Class<?> serviceItf;

    /** 服务提供者对象 */
    private transient Object serviceObject;

    /** 服务方法 */
    private transient Method serviceMethod;

    /** 服务地址 */
    private String serverIp;

    /** 服务端口 */
    private int serverPort;

    /** 超时时间 */
    private long timeout;

    /** 服务权重，负载均衡用 */
    private int weight;

    /** 处于工作的线程数 */
    private int workerThread;

    /** 服务appKey */
    private String appKey;

    /** 分组名称 */
    private String groupName;

    public Class<?> getServiceItf() {
        return serviceItf;
    }

    public void setServiceItf(Class<?> serviceItf) {
        this.serviceItf = serviceItf;
    }

    public Object getServiceObject() {
        return serviceObject;
    }

    public void setServiceObject(Object serviceObject) {
        this.serviceObject = serviceObject;
    }

    public Method getServiceMethod() {
        return serviceMethod;
    }

    public void setServiceMethod(Method serviceMethod) {
        this.serviceMethod = serviceMethod;
    }

    public String getServerIp() {
        return serverIp;
    }

    public void setServerIp(String serverIp) {
        this.serverIp = serverIp;
    }

    public int getServerPort() {
        return serverPort;
    }

    public void setServerPort(int serverPort) {
        this.serverPort = serverPort;
    }

    public long getTimeout() {
        return timeout;
    }

    public void setTimeout(long timeout) {
        this.timeout = timeout;
    }

    public int getWeight() {
        return weight;
    }

    public void setWeight(int weight) {
        this.weight = weight;
    }

    public int getWorkerThread() {
        return workerThread;
    }

    public void setWorkerThread(int workerThread) {
        this.workerThread = workerThread;
    }

    public String getAppKey() {
        return appKey;
    }

    public void setAppKey(String appKey) {
        this.appKey = appKey;
    }

    public String getGroupName() {
        return groupName;
    }

    public void setGroupName(String groupName) {
        this.groupName = groupName;
    }

    /**
     * clone对象
     *
     * @return
     */
    @Override
    public ProviderService clone() {
        ProviderService clone = new ProviderService();
        clone.setServiceItf(this.serviceItf);
        clone.setServiceObject(this.serviceObject);
        clone.setServiceMethod(this.serviceMethod);
        clone.setServerIp(this.serverIp);
        clone.setServerPort(this.serverPort);
        clone.setTimeout(this.timeout);
        clone.setWeight(this.weight);
        clone.setWorkerThread(this.workerThread);
        clone.setAppKey(this.appKey);
        clone.setGroupName(this.groupName);
        return clone;
    }
}
